Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cat-voices): vit ss endpoints generating #1302

Open
wants to merge 4 commits into
base: mve3
Choose a base branch
from

Conversation

damian-molinski
Copy link
Contributor

Description

  • Generating VIT endpoints base on vit.yaml which is hardcoded into openapi dir.
  • bump chopper/chopper_generator versions.
  • add chopper/chopper_generator to melos.yaml because repository package is using it too.

Not sure if vit.yaml is somewhat ill formatted or code generation is not working properly but it was not able to generate correct classes for SimpleProposal and CommunityChoiceProposal, that's why i added overriden_models.dart where i implemented them by hand as it was fastest solution (we'll remove it anyways later).

Moreover types in some endpoints are not defined at all. For example GET fund looks like this

  ///Get available fund
  @deprecated
  @Get(path: '/api/v0/fund')
  Future<chopper.Response> _apiV0FundGet();

where openapi says

  /api/v0/fund:
    get:
      operationId: getCurrentFund
      summary: Get available fund
      tags:
        - fund
      description: |
        Retrieves information on the current treasury fund campaign.
      responses:
        '200':
          description: Valid response
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Fund'
                  - $ref: '#/components/schemas/NextFundInfo'
      deprecated: true

other endpoints are mostly fine but we'll have to keep eye on it.
cc @minikin

Related Issue(s)

Resolves #1298

Please confirm the following checks

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream module

@damian-molinski damian-molinski added review me PR is ready for review dart Pull requests that update Dart code labels Nov 29, 2024
@damian-molinski damian-molinski self-assigned this Nov 29, 2024
Copy link
Contributor

Test Report | ${\color{lightgreen}Pass: 346/346}$ | ${\color{red}Fail: 0/346}$ |

Copy link
Contributor

Test Report | ${\color{lightgreen}Pass: 346/346}$ | ${\color{red}Fail: 0/346}$ |

@@ -1 +1 @@
export 'cat_gateway_api.swagger.dart' show CatGatewayApi;
export 'vit.swagger.dart' show Vit;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does happen with the cat_gateway_api? We will need it as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, forgot about it.

@@ -0,0 +1,100 @@
import 'package:catalyst_voices_services/generated/catalyst_gateway/vit.models.swagger.dart';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if vitss was not under catalyst)gateway because its not part of catalyst gateway.
Just so the distinction is clearer.
Perhaps in package:catalyst_voices_services/generated/vitss/* instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, wanted to do it too but swagger_dart_code_generator allows only one input_folder/output_folder folder.

I was thinking about renaming catalyst_gateway to api because later generated classes have descriptive names anyways.

so from

├── generated
│   └── catalyst_gateway
│       ├── cat_gateway_api.enums.swagger.dart
│       ├── cat_gateway_api.models.swagger.dart
│       ├── cat_gateway_api.models.swagger.g.dart
│       ├── cat_gateway_api.swagger.chopper.dart
│       ├── cat_gateway_api.swagger.dart
│       ├── client_index.dart
│       ├── client_mapping.dart
│       ├── vit.enums.swagger.dart
│       ├── vit.models.swagger.dart
│       ├── vit.models.swagger.g.dart
│       ├── vit.swagger.chopper.dart
│       └── vit.swagger.dart

to

├── generated
│   └── api
│       ├── cat_gateway_api.enums.swagger.dart
│       ├── cat_gateway_api.models.swagger.dart
│       ├── cat_gateway_api.models.swagger.g.dart
│       ├── cat_gateway_api.swagger.chopper.dart
│       ├── cat_gateway_api.swagger.dart
│       ├── client_index.dart
│       ├── client_mapping.dart
│       ├── vit.enums.swagger.dart
│       ├── vit.models.swagger.dart
│       ├── vit.models.swagger.g.dart
│       ├── vit.swagger.chopper.dart
│       └── vit.swagger.dart

does it make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe even rename cat_gateway_api to just cat_gateway

Copy link
Collaborator

@stevenj stevenj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a required change, but a suggestion for clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dart Pull requests that update Dart code review me PR is ready for review
Projects
Status: 🔖 Ready
Development

Successfully merging this pull request may close these issues.

3 participants